;(function show_navMore() {
    var nav_return		= document.getElementById('nav_return');
    var nav_indexfy	= document.getElementById('nav_indexfy');
    var nav_classify	= document.getElementById('nav_classify');
    var nav_shopcar	= document.getElementById('nav_shopcar');
    var nav_mygome= document.getElementById('nav_mygome');
    var nav_morelist	= document.getElementById('nav_list');
    var nav_home		= document.getElementById('nav_home');
    var clicks = 'click';
    //导航连接配置
    var home_url	= ( nav_indexfy && nav_indexfy.href ) || '';
    var class_url		= ( nav_classify && nav_classify.href) || '';
    var shopping_cart_url	= ( nav_shopcar && nav_shopcar.href) || '';
    var my_gome_url			= ( nav_mygome && nav_mygome.href) || '';

    function navMore() {
        if(!nav_morelist) return;

        if (nav_morelist.style.display == "block") {
            nav_morelist.style.display = "none";
        } else {
            nav_morelist.style.display = "block";
        }
    }
    function navHome() {
        window.location.href = home_url;
    }
    function show_subnav(evt) {
        var target = evt.target || evt.srcElement;
        if (target.id == 'nav_new_more') {
            navMore();
            return;
        } else {
            if (target.id == 'nav_classify') {
                window.location.href = class_url;
            } else if (target.id == 'nav_indexfy') {
                window.location.href = home_url;
            }else if (target.id == 'nav_home') {
                window.location.href = nav_home.href ? nav_home.href : '';
            } else if (target.id == 'nav_shopcar') {
                window.location.href = shopping_cart_url;
            } else if (target.id == 'nav_mygome') {
                window.location.href = my_gome_url;
            } else if (target.id == 'sale-sj') {
                sellStatus();
            } else if (target.id == 'sale-xj') {
                sellStatus();
            } else {
                while (target.nodeName.toLowerCase() != "html") {
                    target = target.parentNode;
                }
                if (target.nodeName.toLowerCase() == "html") {
                    nav_morelist && ( nav_morelist.style.display = "none");
                }
            }
        }
    }
    document.addEventListener('touchend', show_subnav, false);
    if (nav_home && nav_home.addEventListener && nav_home.addEventListener != '') {
        nav_home.addEventListener(clicks, navHome, false);
    }
    document.addEventListener('touchmove', function () {
        nav_morelist && ( nav_morelist.style.display = "none" );
    }, false);
})();

;(function(window){
    var cb;
    window.navReturn = function(){
        var nav_return=document.getElementById('nav_return');
        var goback=document.getElementById('goback');
        if(cb==undefined){
            if(nav_return && nav_return.addEventListener && nav_return.addEventListener != '') {
                nav_return.addEventListener('click', function () {
                    if(cb){
                        cb()
                        return
                    }
                    // if (typeof gome_spurl == 'undefined') {
                    //     if (document.referrer == '' || document.referrer == window.location.href) {
                    //         window.location.href = domain_arr.WAP_IP + '/index.html'
                    //     } else {
                    //         history.back()
                    //     }
                    // } else {
                        if (!document.referrer /*|| document.referrer == window.location.href*/) {
                            window.location.href = window.gome_spurl || (domain_arr.WAP_IP + '/index.html')
                        } else {
                            history.back()
                        }
                    // }
                }, false)
            }
            if(goback && goback.addEventListener && goback.addEventListener != '') {
                goback.addEventListener('click', function () {
                    if(cb){
                        cb()
                        return
                    }
                    // if (typeof gome_spurl == 'undefined') {
                    //     if (document.referrer == '' || document.referrer == window.location.href) {
                    //         window.location.href = domain_arr.WAP_IP + '/index.html'
                    //     } else {
                    //         history.back()
                    //     }
                    // } else {
                        if (!document.referrer /*|| document.referrer == window.location.href*/) {
                            window.location.href = window.gome_spurl || (domain_arr.WAP_IP + '/index.html')
                        } else {
                            history.back()
                        }
                    // }
                }, false)
            }
        }else{
            if(nav_return != null){
                nav_return.addEventListener('click',cb,false);
            }
            if(typeof(weixin_flag) != "undefined"){
                if(weixin_flag == 1){
                   if(document.getElementById("wap_address")){
                       document.getElementById("wap_address").style.display='block'
                   }
                }
            }
            if(goback != null){
                goback.addEventListener('click',cb,false);
            }
        }
    }
    window.navReturn.setCallback = function(callback){
        cb = callback;
    }
    navReturn();
})(window);
/*
 * 新头点击更多
*/
(function header_navMore() {
    var oMoreBtn = document.querySelector('.header .moreBtn');
    var oTabNav = document.querySelector('.header .tab-nav');
    var handleMove = function(){
        if(oTabNav && oTabNav.style.display === 'block'){
            oTabNav.style.display = 'none'
            oMoreBtn.setAttribute('active','hide') 
        }else{
            return;
        }
    };
    var navMoreToggle = function(){
        var attr = oMoreBtn.getAttribute('active')
        if(attr == null || attr == 'hide'){
            oMoreBtn.setAttribute('active','show')
            oTabNav.style.display = 'block'
        }
        if(attr == 'show'){
            oMoreBtn.setAttribute('active','hide')
            oTabNav.style.display = 'none'
        }
    }
    var pageClick = function(evt){
        if(oTabNav){
            var target = evt.target || evt.srcElement;
            var targetArr = [];
            targetArr.push(target)
            while (target.nodeName.toLowerCase() != "html") {
                target = target.parentNode;
                targetArr.push(target)
            }
            for(var i = 0; i<targetArr.length;i++){
                if (targetArr[i].className.indexOf('moreBtn')>-1){
                    navMoreToggle();
                    return;
                }
            }
            handleMove();
        }
    }
    document.body.addEventListener('touchmove',handleMove,false);
    document.body.addEventListener('click',pageClick,false)
})();